﻿@using Ornament.Web
@model Ornament.MemberShip.User
@{
    ViewBag.Title = "Info";
    Layout = "~/Views/Shared/App.cshtml";
    var menus = new[]
                       {
                           new
                               {
                                   url="base",
                                   text=Html.GetResourceString("Menu_BasicInfo")
                                   
                               },
                                 new
                               {
                                   url = "ChangePassword",
                                   text =  Html.GetResourceString("Menu_ChangePassword")
                               },
                           new
                               {
                                   url = "Permissions",
                                   text =  Html.GetResourceString("Menu_PermissionsInfo")
                               }
                       };
}
<div class="mainContentWrapper">
    <div id="info" class="rightMainContent">
        <ul>
            <li><a href="#base"><span class="iconContainer">
                @Html.GetResourceString("BasicInfo")</span></a></li>
        </ul>
        <div id="base">
            <fieldset class="cssform">
                <legend>
                    @Html.GetResourceString("BasicInfo")</legend>
                <div style="float: left">
                    <p>
                        <label>
                            @Resources.Basic.Name</label>
                        <input id="Name" name="Name" type="text" value="
                            
                            
                            @Model.Name" />
                    </p>
                    <p>
                        <label>
                            @Resources.Basic.Email
                        </label>
                        <input id="Email" name="Email" type="text" value="@Model.Information.Email " />
                    </p>
                    <p>
                        <label>
                            @Resources.Basic.Phone</label>
                        <input id="Phone" name="Phone" type="text" value="@Model.Information.Phone " />
                    </p>
                </div>
                <div style="float: left; margin-left: 10px; border-left: solid 1px #ccc">
                    <p>
                        @Html.LabelFor(s => s.UpdateTime)
                        <label class="data">
                            @Model.UpdateTime</label>
                    </p>
                    <p>
                        @Html.LabelFor(s => s.CreateTime)
                        <label class="data">
                            @Model.CreateTime</label>
                    </p>
                    <p>
                        @Html.LabelFor(s => s.LastPasswordChangedDate)
                        <label class="data">
                            @Model.LastPasswordChangedDate
                        </label>
                    </p>
                    <p>
                        @Html.LabelFor(s => s.LastLockoutDate)
                        <label class="data">
                            @Model.LastLockoutDate</label>
                    </p>
                    <p>
                        @Html.LabelFor(s => s.LastLoginDate)
                        <label class="data">
                            @Model.LastLoginDate</label>
                    </p>
                    <p>
                        @Html.LabelFor(s => s.LastActivityDate)
                        <label class="data">
                            @Model.LastActivityDate</label>
                    </p>
                </div>
                <div style="clear: both">
                    <input id="BaseInfoSaveButton" value="@Resources.Basic.Save " type="button" />
                </div>
            </fieldset>
        </div>
    </div>
</div>
<div class="leftMenu">
    <div class="panel ui-widget-content ui-widget ui-corner-all" style="margin-top: 0">
        <div class="ui-widget-header ui-corner-all">
            @Html.GetResourceString("Menu")
        </div>
        <div class="verticalMenu">
            <ul>
                @foreach (var item in menus)
                {
                    <li><a href="#@item.url">@item.text</a> <span class="ui-icon ui-icon-bullet"></span>
                    </li>
                }
            </ul>
        </div>
    </div>
</div>
<div style="clear: both">
</div>
@section PageTitle
{
    @OrnamentContext.Current.CurrentUser.LoginId
}
@section header
{
    <style type="text/css">
        .tabsClose
        {
            cursor: pointer;
        }
        .cssform label.data
        {
            width: 12em;
        }
    </style>
    <script src="@Url.Content("~/Scripts/lib/Jquery.ShortCut.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $("#info").tabs({
                cache: true,
                add: function (event, ui) {
                    $("#info").tabs('select', '#' + ui.panel.id);
                },
                tabTemplate: '<li><a href="#{href}" ><span class="iconContainer">#{label}<span class="tabsClose ui-icon ui-icon-circle-close" style="top: -4px;" onclick="closeTab1(this)"></span></span></a></li>'

            });


            $("#BaseInfoSaveButton").button().click(function () {

                var myObj = {
                    Name: $("#Name").val(),
                    Email: $("#Email").val(),
                    Phone: $("#Phone").val()
                };

                $.post('@Url.Action("InfoSave")',
                            { data: $.toJSON(myObj) },
                 function (result) {
                     alert(result.Message);
                 });
            });

            $(".verticalMenu a").click(function () {
                openTab($.trim($(this).text()), $(this).attr("href").substr(1));
                return false;
            });

        });

        function openTab(tabTitle, url) {
            var tab = $("#info ul li a span:contains('" + tabTitle + "')");
            if (tab.length == 0) {
                $("#info").tabs('add', url, tabTitle);
            }
            else {
                var openedTab = $(tab).closest("li");
                var index = openedTab.parent().children().index(openedTab[0]);
                $("#info").tabs('select', index);

            }
        }

        function closeTab1(a) {
            var currentTab = $(a).closest("li");
            var index = currentTab.parent().children().index(currentTab[0]);
            $("#info").tabs('remove', index);

        }
    </script>
}
